home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000056_icon-group-sender _Fri Feb 28 20:57:37 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Mon, 3 Mar 1997 08:32:40 MST
Date: Fri, 28 Feb 1997 20:57:37 -0600 (CST)
Message-Id: <199703010257.UAA23596@dfw-ix9.ix.netcom.com>
X-Sender: bobalex@popd.ix.netcom.com
X-Mailer: Windows Eudora Pro Version 2.1.2
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: Stuart Robinson <srobinso@reed.edu>,
Icon Group <icon-group@cs.arizona.edu>
From: Bob Alexander <bobalex@ix.netcom.com>
Subject: Re: Help with Program
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1723
Here's a little Icon program that does what you asked, I think. I'll leave
it as an exercise to add little improvements like a "local" declaration (not
all that helpful in such a small program, but a good idea as complexity
increases), and maybe comments (it's not a necessary part of the Icon
culture to write cryptic programs). If any questions, feel free to ask.
--- Bob
procedure main()
lineNbr := 0
while line := read() do line ? {
lineNbr +:= 1
(nbr := tab(many(&digits)) &
tab(many(' \t')) &
letter1 := move(1) &
tab(many(' \t')) &
letter2 := move(1) &
pos(0)) | write("*** Line ",lineNbr," is invalid")
if nbr === lastNbr then
write(lineNbr - 1,"-",lineNbr," ",
lastLetter1,letter1," ",lastLetter2,letter2)
lastNbr := nbr; lastLetter1 := letter1; lastLetter2 := letter2
}
end
>I have a number of texts each line of which has been coded for three types
>of information. Each line of the text will be assigned a number and a
>code for two categories. The numbers are just whole numbers (raning from 1
>to 20 or so) and each category has four members (say, ABCD and WXYZ).
>Here is an example text:
>
>1 A X
>1 A Y
>1 B Y
>2 B Y
>
>Note that some successive lines share an index number (as in lines 1 and
>2 and 2 and 3). When that is the case, I would like the program to
>output the members of each category for the matched lines, as below:
>
>1-2 AA XY
>2-3 AB YY
>
>That is it. There are some additional complications, but I think that I
>can solve those at a later date. At the moment, this sort of
>rough-and-ready analysis is all I need.
>
>Any suggestions? Thanks in advance.
>
>--Stuart <srobinso@reed.edu>
>
>
>
>